package com.news.common;

import com.news.utils.JsonUtils;

import java.util.List;

/**
 * @Author:weiming
 * @Date:2021/4/1
 */
public class CommonPage {

    /**
     * 状态码
     */
    private long code;
    /**
     * 提示信息
     */
    private String message;

    /**
     * 数据
     */
    private java.util.List data;

    /**
     * 大小
     */
    private int count;

    public CommonPage(long code, String message, List list) {
        this.code = code;
        this.message = message;
        this.count = list.size();
        this.data = list;
    }

    public CommonPage() {
    }

    public static  String success(List list) {
        CommonPage commonPage = new CommonPage();
        commonPage.setCode(ResultCode.SUCCESS.getCode());
        commonPage.setMessage(ResultCode.SUCCESS.getMessage());
        commonPage.setData(list);
        commonPage.setCount(list.size());
        return JsonUtils.toJson(commonPage);
    }

    public long getCode() {
        return code;
    }

    public void setCode(long code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public List getData() {
        return data;
    }

    public void setData(List data) {
        this.data = data;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }
}
